<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>single-root-element</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
    <div id="app">
        <blog-post 
            v-for="post in posts"
            v-bind:key="post.id"
            v-bind:post="post"
        ></blog-post>
    </div>
    <script>
        // (1) every component must have a single root element (每个组件必须只有一个根元素)
        // (2) `` : 模板字符串
        Vue.component('blog-post', {
            props: ['post'],
            template: `
                <div class="blog-post">
                    <h3>{{ post.title }}</h3>
                    <div v-html="post.content"></div>
                </div>
            `
        });
        var app = new Vue({
            el: '#app',
            data: {
                posts: [
                    { id: 1, title: '111', content: '1111'},
                    { id: 2, title: '222', content: '22'},
                    { id: 3, title: '333', content: '3'}
                ]
            }
        });
    </script>
</body>
</html>
